﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using Weazel.NativeMath;

#endregion

namespace Weazel.NativeMath.Test
{
	[TestClass]
	public class TestIor
	{
		[TestMethod]
		public void TestOR_1()
		{
			Integer a = new Integer(8, "0b00000000", false);
			Integer b = new Integer(8, "0b11111111", false);
			Integer r = new Integer(8, false);

			Assert.AreEqual("11111111", (a | b).ToBinaryString());

			Integer.Or(r, a, b);
			Assert.AreEqual("11111111", r.ToBinaryString());
		}

		[TestMethod]
		public void TestOR_2()
		{
			Integer a = new Integer(8, "0b11110000", false);
			Integer b = new Integer(8, "0b11111111", false);
			Integer r = new Integer(8, false);

			Assert.AreEqual("11111111", (a | b).ToBinaryString());

			Integer.Or(r, a, b);
			Assert.AreEqual("11111111", r.ToBinaryString());
		}

		[TestMethod]
		public void TestOR_3()
		{
			Integer a = new Integer(32, "0xFFFFFF00", false);
			Integer b = new Integer(8, "0xF0", false);
			Integer r = new Integer(32, false);

			Assert.AreEqual("fffffff0", (a | b).ToHexadecimalString());

			Integer.Or(r, a, b);
			Assert.AreEqual("fffffff0", r.ToHexadecimalString());
		}

		[TestMethod]
		public void TestOR_4()
		{
			Integer b = new Integer(64, "0xFFFFFFFFFFFFFF00", false);
			Integer a = new Integer(8, "0xF0", false);
			Integer r = new Integer(64, false);

			Assert.AreEqual("fffffffffffffff0", (a | b).ToHexadecimalString());
			Assert.AreEqual("fffffffffffffff0", (b | a).ToHexadecimalString());

			Integer.Or(r, a, b);
			Assert.AreEqual("fffffffffffffff0", r.ToHexadecimalString());
		}

		[TestMethod]
		public void TestOR_5()
		{
			Integer b = new Integer(64, "0xf0f0f0f0f0f0f0f0", false);
			Integer a = new Integer(64, "0x0f0f0f0f0f0f0f0f", false);
			Integer r = new Integer(32, false);

			Assert.AreEqual("ffffffffffffffff", (a | b).ToHexadecimalString());
			Assert.AreEqual("ffffffffffffffff", (b | a).ToHexadecimalString());

			Integer.Or(r, a, b);
			Assert.AreEqual("ffffffff", r.ToHexadecimalString());
		}

		[TestMethod]
		public void TestOr_SingleBit1()
		{
			Integer b = new Integer(1, "1", false);
			Integer a = new Integer(1, "1", false);
			Integer r = new Integer(1, false);

			Assert.AreEqual("1", (a | b).ToHexadecimalString());
			Assert.AreEqual("1", (b | a).ToHexadecimalString());

			Integer.Or(r, a, b);
			Assert.AreEqual("1", r.ToHexadecimalString());
		}

		[TestMethod]
		public void TestOr_SingleBit2()
		{
			Integer b = new Integer(1, "0", false);
			Integer a = new Integer(1, "1", false);
			Integer r = new Integer(1, false);

			Assert.AreEqual("1", (a | b).ToHexadecimalString());
			Assert.AreEqual("1", (b | a).ToHexadecimalString());

			Integer.Or(r, a, b);
			Assert.AreEqual("1", r.ToHexadecimalString());
		}

		[TestMethod]
		public void TestOr_SingleBit3()
		{
			Integer b = new Integer(1, "0", false);
			Integer a = new Integer(1, "0", false);
			Integer r = new Integer(1, false);

			Assert.AreEqual("0", (a | b).ToHexadecimalString());
			Assert.AreEqual("0", (b | a).ToHexadecimalString());

			Integer.Or(r, a, b);
			Assert.AreEqual("0", r.ToHexadecimalString());
		}
	}
}
